﻿package com.dykj.platform.framework.utils;
/**
 * @Title: DYKJ Platform
 * @Description: SQL 语句处理工具
 * @Copyright: Copyright (c) 2008
 * @Company: DYKJ
 * @author jit@dykj.cn
 * @version 1.0
 */
public class SQLUtils {

	public SQLUtils() {
	}

	/**
	 * 获取查询数量SQL语句
	 * 
	 * @param queryString
	 * @return
	 */
	public static String getCountSQL(String queryString) {
		String countSQL = null;
		//以 select 语句开始
		if (queryString.toLowerCase().startsWith("select ")) {
			int fromindex = queryString.toLowerCase().indexOf(" from ");
			countSQL = "select count(*) " + queryString.substring(fromindex);
		} 
		//以 from 语句开始
		else if (queryString.toLowerCase().startsWith("from "))
			countSQL = "select count(*) " + queryString;
		return countSQL;
	}

}
